﻿using System;
using fastCSharp;

namespace diantou.web.include
{
    /// <summary>
    /// 用户问题的提交记录集合
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true, QueryName = null)]
    partial class contestUserProblemJudges : currentUserView<contestUserProblemJudges>
    {
        /// <summary>
        /// 提交记录计分
        /// </summary>
        private struct judgePoint
        {
            /// <summary>
            /// 测试提交
            /// </summary>
            public diantou.dataAccess.contestJudge Judge;
            /// <summary>
            /// 用户信息
            /// </summary>
            public diantou.dataAccess.user User;
            /// <summary>
            /// 测试得分
            /// </summary>
            public int Point;
            /// <summary>
            /// 用户相关提交
            /// </summary>
            public contest.userJudge UserJudge
            {
                get { return new contest.userJudge { Judge = Judge, UserId = User.Id, IsAdmin = User.Permission == dataModel.user.permission.Admin }; }
            }
            /// <summary>
            /// 提交记录计分
            /// </summary>
            /// <param name="judge">测试提交</param>
            /// <param name="user">当前用户信息</param>
            /// <param name="problem">测试问题</param>
            public judgePoint(diantou.dataAccess.contestJudge judge, diantou.dataAccess.user user, diantou.dataAccess.problem problem)
            {
                Judge = judge;
                User = user;
                Point = judge.GetPoint(problem);
            }
        }
        /// <summary>
        /// 用户问题的提交记录集合
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private judgePoint[] judges;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="problemId"></param>
        /// <returns></returns>
        private bool loadView(int userId, int problemId)
        {
            diantou.dataAccess.problem problem = diantou.dataAccess.clientCache.Problem[problemId];
            diantou.dataAccess.contestJudge[] values = diantou.dataAccess.tcpCall.contestJudge.getUserProblemJudges(userId, problemId);
            judges = values.getArray(value => new judgePoint(value, currentUser, problem));
            return true;
        }
    }
}
